var express = require('express');
var router = express.Router();
const classificationController = require("../controllers/classification_controller")
// 获取美剧列表
router.get("/classification", (req, res) => {
    var {
        page,
        pagesize
    } = req.query

    classificationController.classificationlist({
        page,
        pagesize
    }, ["查询失败", "查询成功"], (result) => {
        res.json(result)
    })
})
// 添加美剧
router.post("/addclassificationTv", (req, res) => {
    const {
        classificationTvObj
    } = req.body
    // const {
    //     doubanId,
    //     title,
    //     rate,
    //     poster
    // } = req.body
    // {
    //     doubanId: Number(doubanId),
    //     title,
    //     rate: Number(rate),
    //     poster
    // }
    classificationController.addclassificationlist(classificationTvObj, ["添加失败", "添加成功"], (result) => {
        res.json(result)
    })
})
// 修改美剧信息
router.patch("/patchclassificationTv", (req, res) => {
    // const {
    //     classificationTvObj
    // } = req.body
    const {
        doubanId,
        title,
        rate,
        poster
    } = req.body
    // {
    //     doubanId: Number(doubanId),
    //     title,
    //     rate: Number(rate),
    //     poster
    // }
    classificationController.patchclassificationlist({
        doubanId: Number(doubanId),
        title,
        rate: Number(rate),
        poster
    }, ["修改失败", "修改成功"], (result) => {
        res.json(result)
    })
})
//删除美剧
router.delete("/deleteclassificationTv", (req, res) => {
    const {classificationTvId}=req.body
    classificationController.deleteclassificationlist(classificationTvId, ["删除失败", "删除成功"], (result) => {
        res.json(result)
    })
})

module.exports = router;
